import Vue from "vue";
import Router from "vue-router";
import Login from "@/pages/Login";
import Register from "@/pages/Register";
import Warning from "@/pages/Warning";
import Show from "@/components/Show";
import DataVisualization from "@/pages/DataVisualization";
import Vaccines from "@/pages/Vaccines";
import Album from "@/pages/Album";
import AlbumShow from "@/pages/AlbumShow";
import Advertisement from "@/pages/Advertisement";
import AdminShow from "@/components/AdminShow";
import Admin from "@/pages/Admin";
import AdPic from "@/pages/AdPic";
import Talk from "@/pages/Talk";


const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router);


export default new Router({
    routes: [
        {
            path: '/login',
            name: '/login', // 路由名称
            component: Login,// 组件对象
        },
        {
            path: '/',
            name: '/',
            component: Advertisement
        },
        {
            path: '/adminShow',
            name: 'adminShow',
            component: AdminShow,
            redirect: '/admin',
            children: [
                {
                    path: '/admin',
                    name: 'admin',
                    component: Admin
                },
                {
                    path: '/adPic',
                    name: 'adPic',
                    component: AdPic
                }
            ]
        },
        {
            path: '/register',
            name: 'register',
            component: Register
        },
        {
            path: '/warning',
            name: 'warning',
            component: Warning
        },
        {
            path: '/show',
            name: 'show',
            component: Show,
            redirect: '/dataVisualization',
            children: [
                {
                    path: '/dataVisualization',
                    name: 'dataVisualization',
                    component: DataVisualization
                },
                {
                    path: '/vaccines',
                    name: 'Vaccines',
                    component: Vaccines
                },
                {
                    path: '/album',
                    name: 'Album',
                    component: Album
                },
                {
                    path: '/albumShow/:id',
                    name: 'AlbumShow',
                    component: AlbumShow
                },
                {
                    path: '/talk',
                    name: 'Talk',
                    component: Talk
                }
            ]
        }
    ]
});